home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
076-100
/
081
/
icon
/
roman.icn
< prev
next >
Wrap
Text File
|
1995-03-13
|
588b
|
24 lines
#
# R O M A N N U M E R A L S
#
# This program takes Arabic numerals from standard input and writes
# the corresponding Roman numerals to standard outout.
procedure main()
local n
while n := read() do
write(roman(n) | "cannot convert")
end
procedure roman(n)
local arabic, result
static equiv
initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
integer(n) > 0 | fail
result := ""
every arabic := !n do
result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
if find("*",result) then fail else return result
end